from flask import Flask
from flask_sqlalchemy import SQLAlchemy

server = Flask(__name__)
server.config["SQLALCHEMY_DATABASE_URI"] = "mysql+pymysql://root:123456@127.0.0.1:3306/bili"
# 如果设置成 True (默认情况)，Flask-SQLAlchemy 将会追踪对象的修改并且发送信号。
server.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
# 绑定app至SQLAlchemy
db = SQLAlchemy(server)

class User(db.Model):
    __tablename__ = 'bili_user_info'
    id = db.Column(db.Integer,primary_key=True)
    userid = db.Column(db.Integer)
    username = db.Column(db.CHAR)
    sex = db.Column(db.CHAR)
    sign = db.Column(db.CHAR)
    levels = db.Column(db.Integer)
    following = db.Column(db.Integer)
    follower = db.Column(db.Integer)
    userface = db.Column(db.CHAR)
    user_url = db.Column(db.CHAR)
    play_sum = db.Column(db.Integer)
    video_count = db.Column(db.Integer)


class Video(db.Model):
    __tablename__ = 'bili_user_video'
    id = db.Column(db.Integer,primary_key=True)
    userid = db.Column(db.Integer)
    tname = db.Column(db.CHAR)
    aid = db.Column(db.Integer)
    title = db.Column(db.CHAR)
    descing = db.Column(db.TEXT)
    views = db.Column(db.Integer)
    danmaku = db.Column(db.Integer)
    reply = db.Column(db.Integer)
    favorite = db.Column(db.Integer)
    coin = db.Column(db.Integer)
    share = db.Column(db.Integer)
    likes = db.Column(db.Integer)
    dislike = db.Column(db.Integer)
    dynamic = db.Column(db.TEXT)